package com.bestcem.xm.deliver.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum WechatMprecordStatusEnum {

    WECHATMPRECORD_STATUS_SENDING(0, "发送中"),
    WECHATMPRECORD_STATUS_SUCCESS(1, "发送成功"),
    WECHATMPRECORD_STATUS_FAILED(2, "发送失败"),
    WECHATMPRECORD_STATUS_DISTRUB(3, "免打扰拦截"),
    WECHATMPRECORD_STATUS_BALANCE_SHORT(4, "钱包余额不足"),
    WECHATMPRECORD_STATUS_CHARGE_FAILED(5, "实发实扣,发送成功,扣费失败"),
    WECHATMPRECORD_STATUS_USER_BLOCK(6, "用户拒收");

    @EnumValue
    private final int value;
    private final String desc;

    public static String getDescByValue(int value) {
        List<WechatMprecordStatusEnum> collect = Arrays.stream(WechatMprecordStatusEnum.values()).filter(one -> one.getValue() == value)
                .collect(Collectors.toList());
        if (CollectionUtils.isEmpty(collect)) {
            return "";
        } else {
            return Objects.requireNonNull(collect.stream().findFirst().orElse(null)).getDesc();
        }
    }
}
